import request from '@/axios'

//获取枚举数据
export const getEnumApi = (params?: any) => {
  return request.get({ url: '/admin/wholesalAssets/resource', params })
}
//获取普通订单列表枚举数据
export const getOrderEnumApi = (params?: any) => {
  return request.get({ url: '/admin/order/resource', params })
}
//获取列表数据
export const getListApi = (params?: any) => {
  return request.get({ url: '/admin/order', params })
}
//获取详情数据
export const getDetailApi = (id: string | number): any => {
  return request.get({ url: `/admin/order/${id}` })
}
//复制订单
export const copyOrderApi = (id: string | number): any => {
  return request.get({ url: `/admin/order/copy/${id}` })
}
//获取审核详情数据
export const getReviewDetailApi = (id: string | number): any => {
  return request.get({ url: `/admin/order/review/${id}` })
}
//卖家备注修改
export const orderRemarkApi = (id: string | number, data?: any) => {
  return request.put({ url: `/admin/order/remark/${id}`, data })
}
//普通订单-确认已支付
export const orderSurePaymentApi = (id: string | number, data?: any) => {
  return request.put({ url: `/admin/order/confirm/${id}`, data })
}
//普通订单-取消订单
export const orderCancelApi = (id: string | number, data?: any) => {
  return request.put({ url: `/admin/order/cancel/${id}`, data })
}
//普通订单-撤销订单
export const orderCancelUpdateApi = (id: string | number, data?: any) => {
  return request.put({ url: `/admin/order/cancelUpdate/${id}`, data })
}
//订单删除
export const orderDeleteApi = (id: string | number, data?: any) => {
  return request.delete({ url: `/admin/order/delete/${id}`, data })
}
//获取自提地址数据
export const getPickUpAddressApi = (id: string | number, params?: any) => {
  return request.get({ url: `/admin/warehouse/${id}`, params })
}
//获取快递运费数据
export const getFreightApi = (data?: any) => {
  return request.post({ url: `/admin/LogisticsRules/logisticsFee`, data })
}
//获取收货地址列表数据
export const getDeliveryAddressListApi = (params?: any) => {
  return request.get({ url: '/admin/address', params })
}
//普通订单-新增
export const createDataApi = (data) => {
  return request.post({ url: '/admin/order', data })
}
//普通订单-更新
export const editDataApi = (id: string | number, data) => {
  return request.put({ url: `/admin/order/${id}`, data })
}
//普通订单-审核通过
export const approvedDataApi = (id: string | number, data?: Record<string, any>) => {
  return request.put({ url: `/admin/order/examine/${id}`, data })
}
//普通订单-发货
export const deliveryDataApi = (data) => {
  return request.post({ url: '/admin/order/delivery', data })
}
//普通订单-收货
export const receivingDataApi = (data) => {
  return request.post({ url: '/admin/order/receipt', data })
}
//获取国家枚举数据
export const getCountryEnumApi = (params?: any) => {
  return request.get({ url: '/admin/region/country', params })
}
//获取区枚举数据
export const getAreaEnumApi = (params?: any) => {
  return request.get({ url: '/admin/region/area', params })
}
//更新地址信息
export const editAddressInfoApi = (data): Promise<IResponse> => {
  return request.put({ url: '/admin/address', data })
}
//更新地址信息
export const deleteAddressInfoApi = (id: string | number, user_id: string | number) => {
  return request.delete({ url: `/admin/address`, data: { id, user_id } })
}
//新增地址信息
export const createAddressInfoApi = (data) => {
  return request.post({ url: '/admin/address', data })
}

//普通订单-库存转换类型提交
export const inventoryTypeConversionApi = (data) => {
  return request.post({ url: '/admin/inventory/transSaveByOrder', data })
}
//普通订单-库存转换类型底部列表
export const getConversionListApi = (data: any) => {
  return request.post({ url: '/admin/order/getInventory', data })
}
//普通订单-库存转换类型枚举
export const getConversionTypeApi = (params?: any) => {
  return request.get({ url: '/admin/order/transEnum', params })
}

export const orderOperationLogApi = (params: any) => {
  return request.get({ url: '/admin/order/approvalRecords', params })
}

// 获取操作记录
export const orderOperateRecordsApi = (params: any) => {
  return request.get({ url: '/admin/order/operateRecords', params })
}

export const associatedPurchaseOrdersApi = (params: any) => {
  return request.get({ url: '/admin/order/associatedPurchaseOrders', params })
}

export const contractPreviewApi = (params: any) => {
  return request.get({ url: '/admin/order/contractPreview', params })
}

export const uploadFilingcabinetApi = (data: any) => {
  return request.post({ url: '/admin/filingcabinet', data })
}

export const filingFieldEnumApi = (params: any) => {
  return request.get({ url: '/admin/filingcabinet/fieldEnum', params })
}

export const deleteFilingcabinetApi = (id: string | number) => {
  return request.delete({ url: `/admin/filingcabinet`, data: { id } })
}

// 修改订单物流信息
export const editLogisticsOrderApi = (data): Promise<IResponse> => {
  return request.put({ url: '/admin/logisticsOrder/' + data.id, data })
}

//锁定库存
export const lockInventoryApi = (data) => {
  return request.post({ url: '/admin/order/lockInventory', data })
}

//取消发货
export const cancelDeliveryApi = (data: any) => {
  return request.post({ url: '/admin/order/cancelDelivery', data })
}

//部分发货申请
export const partDeliveryApplyApi = (data: any) => {
  return request.post({ url: '/admin/orderPartDeliveryApply', data })
}

//部分发货申请列表
export const partDeliveryApplyListApi = (params: any) => {
  return request.get({ url: '/admin/orderPartDeliveryApply', params })
}

//部分发货审核
export const partDeliveryApplyAuditApi = (data: any) => {
  return request.put({ url: '/admin/orderPartDeliveryApply', data })
}

// 校对异常商品
export const checkExceptionOrderItem = (id: string | number, data: any): Promise<IResponse> => {
  return request.put({ url: `/admin/order/check_exception_order_item/${id}`, data })
}

// 无需发货
export const noDeliveryApi = (data: any) => {
  return request.post({ url: '/admin/order/no_delivery', data })
}

// 检查商品是否有电源线
export const hasPowerlineApi = (params?: any) => {
  return request.get({ url: '/admin/product/hasPowerline', params })
}
